import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/user_info_entity.dart';

UserInfoEntity $UserInfoEntityFromJson(Map<String, dynamic> json) {
  final UserInfoEntity userInfoEntity = UserInfoEntity();
  final String? uid = jsonConvert.convert<String>(json['uid']);
  if (uid != null) {
    userInfoEntity.uid = uid;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    userInfoEntity.name = name;
  }
  final String? bossName = jsonConvert.convert<String>(json['bossName']);
  if (bossName != null) {
    userInfoEntity.bossName = bossName;
  }
  final String? mobile = jsonConvert.convert<String>(json['mobile']);
  if (mobile != null) {
    userInfoEntity.mobile = mobile;
  }
  final String? spareMobile = jsonConvert.convert<String>(json['spareMobile']);
  if (spareMobile != null) {
    userInfoEntity.spareMobile = spareMobile;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    userInfoEntity.avatar = avatar;
  }
  final int? cashBalance = jsonConvert.convert<int>(json['cashBalance']);
  if (cashBalance != null) {
    userInfoEntity.cashBalance = cashBalance;
  }
  final String? cashBalanceStr = jsonConvert.convert<String>(
      json['cashBalanceStr']);
  if (cashBalanceStr != null) {
    userInfoEntity.cashBalanceStr = cashBalanceStr;
  }
  final String? marginAmountStr = jsonConvert.convert<String>(
      json['marginAmountStr']);
  if (marginAmountStr != null) {
    userInfoEntity.marginAmountStr = marginAmountStr;
  }
  final int? userRole = jsonConvert.convert<int>(json['userRole']);
  if (userRole != null) {
    userInfoEntity.userRole = userRole;
  }
  final UserInfoBank? bank = jsonConvert.convert<UserInfoBank>(json['bank']);
  if (bank != null) {
    userInfoEntity.bank = bank;
  }
  final UserInfoEffect? effect = jsonConvert.convert<UserInfoEffect>(
      json['effect']);
  if (effect != null) {
    userInfoEntity.effect = effect;
  }
  final UserInfoTargetSite? targetSite = jsonConvert.convert<
      UserInfoTargetSite>(json['targetSite']);
  if (targetSite != null) {
    userInfoEntity.targetSite = targetSite;
  }
  final List<UserInfoPrivis>? privis = (json['privis'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<UserInfoPrivis>(e) as UserInfoPrivis)
      .toList();
  if (privis != null) {
    userInfoEntity.privis = privis;
  }
  return userInfoEntity;
}

Map<String, dynamic> $UserInfoEntityToJson(UserInfoEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['uid'] = entity.uid;
  data['name'] = entity.name;
  data['bossName'] = entity.bossName;
  data['mobile'] = entity.mobile;
  data['spareMobile'] = entity.spareMobile;
  data['avatar'] = entity.avatar;
  data['cashBalance'] = entity.cashBalance;
  data['cashBalanceStr'] = entity.cashBalanceStr;
  data['marginAmountStr'] = entity.marginAmountStr;
  data['userRole'] = entity.userRole;
  data['bank'] = entity.bank?.toJson();
  data['effect'] = entity.effect?.toJson();
  data['targetSite'] = entity.targetSite?.toJson();
  data['privis'] = entity.privis?.map((v) => v.toJson()).toList();
  return data;
}

extension UserInfoEntityExtension on UserInfoEntity {
  UserInfoEntity copyWith({
    String? uid,
    String? name,
    String? bossName,
    String? mobile,
    String? spareMobile,
    String? avatar,
    int? cashBalance,
    String? cashBalanceStr,
    String? marginAmountStr,
    int? userRole,
    UserInfoBank? bank,
    UserInfoEffect? effect,
    UserInfoTargetSite? targetSite,
    List<UserInfoPrivis>? privis,
  }) {
    return UserInfoEntity()
      ..uid = uid ?? this.uid
      ..name = name ?? this.name
      ..bossName = bossName ?? this.bossName
      ..mobile = mobile ?? this.mobile
      ..spareMobile = spareMobile ?? this.spareMobile
      ..avatar = avatar ?? this.avatar
      ..cashBalance = cashBalance ?? this.cashBalance
      ..cashBalanceStr = cashBalanceStr ?? this.cashBalanceStr
      ..marginAmountStr = marginAmountStr ?? this.marginAmountStr
      ..userRole = userRole ?? this.userRole
      ..bank = bank ?? this.bank
      ..effect = effect ?? this.effect
      ..targetSite = targetSite ?? this.targetSite
      ..privis = privis ?? this.privis;
  }
}

UserInfoTargetSite $UserInfoTargetSiteFromJson(Map<String, dynamic> json) {
  final UserInfoTargetSite userInfoTargetSite = UserInfoTargetSite();
  final String? sysName = jsonConvert.convert<String>(json['sysName']);
  if (sysName != null) {
    userInfoTargetSite.sysName = sysName;
  }
  final String? sysCn = jsonConvert.convert<String>(json['sysCn']);
  if (sysCn != null) {
    userInfoTargetSite.sysCn = sysCn;
  }
  final String? owner = jsonConvert.convert<String>(json['owner']);
  if (owner != null) {
    userInfoTargetSite.owner = owner;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    userInfoTargetSite.name = name;
  }
  final String? logo = jsonConvert.convert<String>(json['logo']);
  if (logo != null) {
    userInfoTargetSite.logo = logo;
  }
  return userInfoTargetSite;
}

Map<String, dynamic> $UserInfoTargetSiteToJson(UserInfoTargetSite entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['sysName'] = entity.sysName;
  data['sysCn'] = entity.sysCn;
  data['owner'] = entity.owner;
  data['name'] = entity.name;
  data['logo'] = entity.logo;
  return data;
}

extension UserInfoTargetSiteExtension on UserInfoTargetSite {
  UserInfoTargetSite copyWith({
    String? sysName,
    String? sysCn,
    String? owner,
    String? name,
    String? logo,
  }) {
    return UserInfoTargetSite()
      ..sysName = sysName ?? this.sysName
      ..sysCn = sysCn ?? this.sysCn
      ..owner = owner ?? this.owner
      ..name = name ?? this.name
      ..logo = logo ?? this.logo;
  }
}

UserInfoPrivis $UserInfoPrivisFromJson(Map<String, dynamic> json) {
  final UserInfoPrivis userInfoPrivis = UserInfoPrivis();
  final String? sysName = jsonConvert.convert<String>(json['sysName']);
  if (sysName != null) {
    userInfoPrivis.sysName = sysName;
  }
  final String? sysCn = jsonConvert.convert<String>(json['sysCn']);
  if (sysCn != null) {
    userInfoPrivis.sysCn = sysCn;
  }
  final String? owner = jsonConvert.convert<String>(json['owner']);
  if (owner != null) {
    userInfoPrivis.owner = owner;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    userInfoPrivis.name = name;
  }
  return userInfoPrivis;
}

Map<String, dynamic> $UserInfoPrivisToJson(UserInfoPrivis entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['sysName'] = entity.sysName;
  data['sysCn'] = entity.sysCn;
  data['owner'] = entity.owner;
  data['name'] = entity.name;
  return data;
}

extension UserInfoPrivisExtension on UserInfoPrivis {
  UserInfoPrivis copyWith({
    String? sysName,
    String? sysCn,
    String? owner,
    String? name,
  }) {
    return UserInfoPrivis()
      ..sysName = sysName ?? this.sysName
      ..sysCn = sysCn ?? this.sysCn
      ..owner = owner ?? this.owner
      ..name = name ?? this.name;
  }
}

UserInfoBank $UserInfoBankFromJson(Map<String, dynamic> json) {
  final UserInfoBank userInfoBank = UserInfoBank();
  final String? withdrawAcct = jsonConvert.convert<String>(
      json['withdrawAcct']);
  if (withdrawAcct != null) {
    userInfoBank.withdrawAcct = withdrawAcct;
  }
  final String? withdrawBank = jsonConvert.convert<String>(
      json['withdrawBank']);
  if (withdrawBank != null) {
    userInfoBank.withdrawBank = withdrawBank;
  }
  final String? withdrawName = jsonConvert.convert<String>(
      json['withdrawName']);
  if (withdrawName != null) {
    userInfoBank.withdrawName = withdrawName;
  }
  return userInfoBank;
}

Map<String, dynamic> $UserInfoBankToJson(UserInfoBank entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['withdrawAcct'] = entity.withdrawAcct;
  data['withdrawBank'] = entity.withdrawBank;
  data['withdrawName'] = entity.withdrawName;
  return data;
}

extension UserInfoBankExtension on UserInfoBank {
  UserInfoBank copyWith({
    String? withdrawAcct,
    String? withdrawBank,
    String? withdrawName,
  }) {
    return UserInfoBank()
      ..withdrawAcct = withdrawAcct ?? this.withdrawAcct
      ..withdrawBank = withdrawBank ?? this.withdrawBank
      ..withdrawName = withdrawName ?? this.withdrawName;
  }
}

UserInfoEffect $UserInfoEffectFromJson(Map<String, dynamic> json) {
  final UserInfoEffect userInfoEffect = UserInfoEffect();
  final String? monthEffect = jsonConvert.convert<String>(json['monthEffect']);
  if (monthEffect != null) {
    userInfoEffect.monthEffect = monthEffect;
  }
  final String? rtEffect = jsonConvert.convert<String>(json['rtEffect']);
  if (rtEffect != null) {
    userInfoEffect.rtEffect = rtEffect;
  }
  final String? welfareEffect = jsonConvert.convert<String>(
      json['welfareEffect']);
  if (welfareEffect != null) {
    userInfoEffect.welfareEffect = welfareEffect;
  }
  return userInfoEffect;
}

Map<String, dynamic> $UserInfoEffectToJson(UserInfoEffect entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['monthEffect'] = entity.monthEffect;
  data['rtEffect'] = entity.rtEffect;
  data['welfareEffect'] = entity.welfareEffect;
  return data;
}

extension UserInfoEffectExtension on UserInfoEffect {
  UserInfoEffect copyWith({
    String? monthEffect,
    String? rtEffect,
    String? welfareEffect,
  }) {
    return UserInfoEffect()
      ..monthEffect = monthEffect ?? this.monthEffect
      ..rtEffect = rtEffect ?? this.rtEffect
      ..welfareEffect = welfareEffect ?? this.welfareEffect;
  }
}